<?php
include("../../includes/dbInfo.php");
$sid = $_POST["swimmerID"];
// Get all performance records for the given swimmer and display in a table.
$query = "SELECT `swimPerformance`.`eventID`, `swimPerformance`.`time`, `swimPerformance`.`place`,
			`ls_events`.`name`, `ls_events`.`eventType`, `ls_events`.`eventLength`, `ls_events`.`eventDate`
			FROM `swimPerformance`, `ls_events`
			WHERE `swimPerformance`.`swimmerID` = '$sid'
			AND `swimPerformance`.`eventID` = `ls_events`.`eventID`
			ORDER BY `ls_events`.`eventDate` DESC";
$result = mysql_query($query) or die("Error getting swimmer performance for coach: " . mysql_error());
// Display the performance history of the swimmer in a table.
if(mysql_num_rows($result) != 0) {
	echo "<table id='blueTable'><tr><th>Event</th><th>Date</th><th>Type</th><th>Length</th><th>Time</th><th>Place</th></tr>";
	$i = 0;
	while($rows = mysql_fetch_assoc($result)) {
		$style = (($i % 2) == 0) ? "even" : "odd";
		echo "<tr class='$style'><td>" . $rows["name"] . "</td><td>" . $rows["eventDate"] . "</td><td>" . $rows["eventType"] .
			"</td><td>" . $rows["eventLength"] . "</td><td>" . $rows["time"] . "</td><td>" . $rows["place"] . "</td></tr>";
		$i++;
	}
	echo "</table>";
}
else {
	echo "The selected swimmer has no swim performance on record.";
}
?>